// import 'promise-polyfill/src/polyfill'
import {h, patch} from './render'
// import axios from 'axios'
 
class Reader {
    constructor () {
        console.log('初始化')
    }

    async showName (params: string): Promise<void> {
        const res = await Promise.resolve('1')
        console.log(`${params}${res}`)
    }
    
    setName (name: string): string {
        return name
    }

    template (name: string): void {
        console.log(`${name} taoyang`)
    }
    someFn () {
        alert()
    }

    async render () {
        const container: HTMLElement = document.getElementById('container') as HTMLElement
        // const image = await axios.get('http://localhost:8080/reader/reader/image?viewMode=mix&_b=3.2.0&_=1645413225875&file=3.ofd&_v=1644917132494&_i=0&_p=96',
        //     {
        //         withCredentials: false
        //     })
        const vnode = h('div#container.two.classes', { on: { click: this.someFn } }, [
            h('span', { style: { fontWeight: 'bold' } }, 'This is bold'),
            ' and this is just normal text',
            h('a', { props: { href: '/foo' } }, 'I\'ll take you places!'),
        ])

        patch(container, vnode)
        
    }
}

export default Reader

